package com.woniuxy.life.filesystem.api.feign;

import com.woniuxy.life.core.api.CommonResult;
import com.woniuxy.life.core.api.ServiceNameConstants;
import com.woniuxy.life.filesystem.api.feign.factory.RemoteMinIoUploadServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(contextId = "remoteMinIoUploadService",
        value= ServiceNameConstants.FILESYSTEM_SERVICE ,
        fallbackFactory = RemoteMinIoUploadServiceFallbackFactory.class )
public interface RemoteMinIoUploadService {

    @PostMapping(value = "/minio/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public CommonResult upload(@RequestPart(value = "file") MultipartFile file);

    @PostMapping(value = "/minio/delete")
    public CommonResult delete(String objName);

    @GetMapping("/download")
    public ResponseEntity download(@RequestParam("filename") String filename) ;

}
